package com.wnhz.trim.plan.service.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wnhz.trim.domain.entity.Designer;
import com.wnhz.trim.plan.service.dao.PlanDao;
import com.wnhz.trim.plan.service.service.PlanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
@Slf4j
public class PlanServiceImpl implements PlanService {

    @Autowired


    private PlanDao planDao;


    @Override
    public void add(Designer designer) {


        planDao.insert(designer);//增

    }

    @Override
    public void delete(int id) {
        planDao.deleteById(id);    //删

    }

    @Override
    public void update(Designer designer) {
        planDao.updateById(designer);     //改

    }

    @Override
    public List<Designer> findByNameLike(String name) {
        LambdaQueryWrapper<Designer> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(Designer::getName,name);
        return planDao.selectList(queryWrapper);     //更具名字模糊查询
    }


    @Override
    public Designer findNameById(int id) {
        Designer designer = planDao.selectById(id);     //根据ID查单条
        return designer;
    }

    @Override
    public List<Designer> findAll() {
        return planDao.selectList(null);   //全查
    }
}
